package cn.glc.daily.life.infrastructure.repository.mysql;

import cn.glc.daily.life.infrastructure.dao.DictDao;
import cn.glc.daily.life.infrastructure.po.DictPo;
import cn.glc.daily.life.model.dto.dict.DictDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 字典
 *
 * @author simon
 * @date 2021/4/13 12:00
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
@Repository
public class DictRepository extends ServiceImpl<DictDao, DictPo> implements IService<DictPo> {

    /**
     * 分页查询
     *
     * @param page
     * @param dictDto
     * @return
     */
    public IPage<DictPo> listPage(Page page, DictDto dictDto) {
        return super.baseMapper.listPage(page, dictDto);
    }

    /**
     * 通过code 查询字典数据
     *
     * @param code
     * @return
     */
    public DictPo findByCode(String code) {
        return super.baseMapper.findByCode(code);
    }

    /**
     * 非分页 - 查询指定节点下的所有数据
     *
     * @param dictDto
     * @return
     */
    public List<DictPo> queryChildrenByCondition(DictDto dictDto) {
        return super.baseMapper.queryChildrenByCondition(dictDto);
    }

    /**
     * 非分页 - 查询指定code数据
     *
     * @param dictDto
     * @return
     */
    public DictPo queryByCondition(DictDto dictDto) {
        return super.baseMapper.queryByCondition(dictDto);
    }

    /**
     * 查询指定父节点的下一级子树的数量
     *
     * @param code
     * @return
     */
    public Integer queryChildrenCountByCondition(String code) {
        return super.baseMapper.queryChildrenCountByCondition(code);
    }
}
